<template>
  <div class="box" v-loading="loading">
    <div class="title">
      <div>
      <svg t="1742369042536" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
           p-id="31305" width="24" height="24"
      >
        <path
          d="M628.629333 479.018667l108.629334 64.810666 3.562666 201.792a165.226667 165.226667 0 0 1-83.861333 172.245334C576.213333 962.218667 474.453333 933.333333 429.717333 853.333333c-4.202667-7.530667 115.84-75.2 203.392-120.362666l-4.48-253.930667z"
          fill="#3779FA" p-id="31306"
        ></path>
        <path
          d="M600.512 582.293333l-0.042667 125.781334-172.437333 106.965333a167.893333 167.893333 0 0 1-191.978667 17.365333C156.16 786.581333 128.746667 685.141333 174.784 605.866667c4.330667-7.466667 124.608 59.797333 208.725333 111.018666l217.002667-134.613333zM652.373333 336.106667l177.877334 97.834666c64.405333 23.850667 109.696 86.037333 108.373333 158.208-1.664 91.562667-77.738667 164.544-169.941333 162.986667-4.586667-0.064-6.485333-38.485333-6.613334-89.173333v-11.434667c0.128-42.666667 1.386667-92.16 3.264-134.357333l-223.829333-123.093334 110.890667-60.970666z"
          fill="#81B9FF" p-id="31307"
        ></path>
        <path
          d="M252.373333 264.256c5.973333 0 8.533333 64.512 8.682667 136.64v18.666667l-0.256 32.554666c-0.213333 16.170667-0.512 32.042667-0.917333 47.018667l225.941333 119.210667-109.781333 62.869333-179.562667-94.72C131.669333 563.754667 85.290667 502.378667 85.333333 430.186667c0.064-91.584 74.858667-165.866667 167.04-165.930667z"
          fill="#3779FA" p-id="31308"
        ></path>
        <path
          d="M607.232 173.226667c2.88 5.376-56.661333 39.637333-123.008 74.666666l-16.704 8.746667a3458.282667 3458.282667 0 0 1-65.749333 33.429333V544l-107.477334-66.688v-201.813333a165.269333 165.269333 0 0 1 86.869334-170.773334c81.514667-42.944 182.72-12.266667 226.069333 68.48z"
          fill="#81B9FF" p-id="31309"
        ></path>
        <path
          d="M805.013333 191.146667c78.229333 48.576 102.08 150.890667 53.269334 228.522666-3.328 5.290667-66.261333-30.805333-131.968-71.68l-10.666667-6.677333c-21.376-13.397333-42.688-27.093333-62.037333-39.808L432 428.501333l4.437333-125.717333 176.106667-100.906667a167.914667 167.914667 0 0 1 192.469333-10.730666z"
          fill="#3779FA" p-id="31310"
        ></path>
      </svg>
      Ai每日速递
      </div><div class="date"  v-if="dateCheck" @dblclick="dateCheck=false">{{data.date}}</div><el-date-picker
      v-else
      v-model="timeValueArr"
      type="date"
      @change="checkTime"
      style="width: 140px;font-size:12px;"
    >
    </el-date-picker>
    </div>
    <div class="contents">
      <el-carousel  type="card" :interval="5000">
        <el-carousel-item v-for="(item,idx) in data.jsonData" class="aiMsg-item" >
          <div class="textTitle" style="margin:0 0 10px 0">{{ item.cate }}</div>
          <div class="textDesc">{{ item.text }}</div>
          <div class="links">
            <a :href="`https://wz.mala.cn/wz/wzinfo?wid=${url[0]}`" target="_blank" v-for="(url,idx) in item.ary">{{url[1]}}</a>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>
<style lang="scss" scoped>
::v-deep .el-carousel__container {
  height: 300px;
  .el-carousel__item {
    height: 300px;
  }
  .el-date-editor .el-input__inner{
     padding:0 !important;
  }
}
::v-deep .el-carousel__indicators--outside{
  margin-top:30px !important;
}
.contents {
  .aihot{
    font-size:12px;
    color:#333;
    margin: 7px 0;
  }
  .aiMsg-item {
    margin:20px 0;
    padding: 20px;
    border-radius: 5px;
    background: rgba(237, 242, 253, 1);
    //box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  }

  .textTitle {
    font-size: 16px;
    font-weight: bolder;
    color: #000;
  }
  .links{
    background: #fff;
    padding:10px;
    margin-top:10px;
    border-radius: 5px;
    position: relative;
    .aihot{
      position: absolute;
      right:10px;
      top:2px;
      color:red;
    }
    a{
      margin:10px 0;
      font-size:12px;
      width: 100%;
      color: #3779fa;
      display: block;
      //CSS3只显示一行
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-decoration: none;
    }
  }
  .textDesc {
    color: #999;
    line-height: 20px;
    font-size: 14px;
    //CSS3控制最多显示4行
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
  }
}

.title {
  display: flex;
  align-items: center;
  color: #3779fa;
  font-weight: bolder;
  font-size: 20px;

  svg {
    margin-right: 10px;
  }
}

.box {
  min-height: 300px;
  .title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    >div{
      display: flex;
      align-items: center;
    }
    .date{
      color:#666;
      font-size:12px;
    }
  }
}
</style>

<script>
import { getEverytips } from '@/api/data'

export default {
  name: 'EveryDay',
  data() {
    return {
      loading: true,
      dateCheck:true,
      timeValueArr:'',
      data: []
    }
  },
  created() {
    this.getData()
  },
  watch: {
    timeValueArr(newdata,old) {
     if(!newdata || newdata=='null'){
       this.dateCheck=true;
       this.timeValueArr = this.data.dateline
     }
    }
  },
  methods: {
    checkTime(e){
      if(e=='null' || !e){
        return false
      }
      this.loading = true
      getEverytips({time:e}).then(r => {
        this.loading = false
        this.data = r.data
        this.timeValueArr = r.data.dateline
        this.dateCheck=true;
      }).catch(e=>{
        this.loading = false
        this.dateCheck=true;
        this.$message.error('该时间下没数据~')
        return false
      })
    },
    getData() {
      getEverytips().then(r => {
        this.loading = false
        this.data = r.data
        this.timeValueArr = r.data.dateline
      })
    }
  }
}
</script>
